/*
 * 类名称:LoanPurposeServiceImpl.java
 * 包名称:com.lht.admin.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2020-01-02 00:04:01        ZhengZhanWu     初版做成
 */
package com.lht.admin.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lht.admin.dao.LoanPurposeDao;
import com.lht.admin.entity.LoanPurposeEntity;
import com.lht.admin.service.LoanPurposeService;
import com.lht.admin.utils.QueryPlus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 贷款用途管理表Service实现类
 *
 * @author ZhengZhanWu
 * @date 2020-01-02 00:04:01
 */
@Service("loanPurposeService")
public class LoanPurposeServiceImpl extends ServiceImpl<LoanPurposeDao, LoanPurposeEntity> implements LoanPurposeService {

    @Override
    public List<LoanPurposeEntity> queryAll(Map<String, Object> params) {
        params.put("sidx", "T.sort");
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<LoanPurposeEntity> page = new QueryPlus<LoanPurposeEntity>(params).getPage();
        return page.setRecords(baseMapper.selectLoanPurposePage(page, params));
    }

    @Override
    public boolean add(LoanPurposeEntity loanPurpose) {
        return this.save(loanPurpose);
    }

    @Override
    public boolean update(LoanPurposeEntity loanPurpose) {
        return this.updateById(loanPurpose);
    }

    @Override
    public boolean delete(Long id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(Long[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
